<template>
	<view class="index-nav">
		<view class="title">园区应用</view>
		<view class="nav-box">
			<view class="nav" v-for="item in navListData" :key="item.id" @click="clickNav(item)">
				<image class="nav-img" :src="item.img" mode=""></image>
				<text class="nav-text">{{ item.title }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { navList } from '../../mock/index/index.js';
	import { mapState } from 'vuex';
	export default {
		data() {
			return {
				navList
			};
		},
		computed: {
			...mapState(['userInfo']),
			navListData() {
				if (this.userInfo.user_role === 'leader') {
					return this.navList;
				} else {
					return this.navList.filter(item => item.user_role === 'normal')
				}
			}
		},
		methods: {
			clickNav(item) {
				uni.navigateTo({
					url: item.url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.index-nav {
		padding: 20px 50rpx;
		/* #ifndef APP-PLUS */
		margin-top: 195px;
		/* #endif */
		/* #ifdef APP-PLUS */
		margin-top: 215px;
		/* #endif */
		background-color: #ffffff;
		.title {
			margin-bottom: 20px;
		
			font-size: 16px;
			
			color: $uni-text-color;
		}
		.nav-box {
			display: flex;
			flex-wrap: wrap;
			.nav {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				
				width: 120rpx;
				height: 53px;
				margin-right: 56rpx;
				margin-bottom: 20px;
				&-img {
					width: 48rpx;
					height: 48rpx;
				}
				&-text {
					font-size: 28rpx;
					
					color: #999999;
				}
				&:nth-child(4n) {
					margin-right: 0;
				}
				&:nth-last-child(1), &:nth-last-child(2), &:nth-last-child(3), &:nth-last-child(4) {
					margin-bottom: 0;
				} 
			}
		}
	}
</style>
